package com.fund.user.controller;

import com.fund.common.pojo.Result;
import com.fund.user.pojo.entity.User;
import com.fund.user.service.UserService;
import com.fund.user.utils.JwtTool;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;

@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {

    @Autowired
    UserService userService;

    @PostMapping(value = "/register")
    public Result register(@RequestBody User user) {
        System.out.println(user);
        boolean save = userService.save(user);
        return Result.success(save);
    }

    @PostMapping("/login")
    public Result login(@RequestBody User user) throws Exception {
        return Result.success(userService.login(user));
    }

    @GetMapping
    public Result test(){
        return Result.success("hello world");
    }

}
